import { useContext } from "react";
import { CounterContext } from "./indexFather";

// function ReducerComponent({state,dispatch}) {
function ReducerComponent() {
  console.log("ReducerComponent");
  const { state, dispatch } = useContext(CounterContext);
  return (
    <div>
      <h1>Count: {state.count}</h1>
      <button onClick={() => dispatch({ type: "increment" })}>Increment</button>
      <button onClick={() => dispatch({ type: "decrement" })}>Decrement</button>
      <button onClick={() => dispatch({ type: "reset" })}>Reset</button>
    </div>
  );
}

export default ReducerComponent;
